package org.example.taxi.repository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class HiveRepository {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public List<Map<String, Object>> query(String sql) {
        return this.jdbcTemplate.queryForList(sql);
    }

    public List<Map<String, Object>> chart2() {
        return query("select pickup_hour AS x,num AS y from hourly_trips");
    }

    public List<Map<String, Object>> chart3() {
        return query("select borough AS `name`,num AS `value` from location_trip_count");
    }

    public List<Map<String, Object>> chart4() {
        return query("select CONCAT(passenger_count,'人') AS `name`,num AS `value` from passenger_distribution");
    }

    public List<Map<String, Object>> chart5() {
        return query("select payment_type AS `name`,num AS `value` from payment_type_stats");
    }

    public List<Map<String, Object>> chart6() {
        return query("select borough AS x,num AS y from top_pickup_boroughs");
    }

    public List<Map<String, Object>> chart7() {
        return query("select CONCAT(CONCAT(pickup_borough,pickup_c_zone),'->',CONCAT(dropoff_borough,dropoff_c_zone)) AS x,num AS y from top_route_pairs");
    }

    public List<Map<String, Object>> chart8() {
        return query("select vendor_id AS `name`,num AS `value` from vendor_trip_stats");
    }

    public List<Map<String, Object>> chart9() {
        return query("select pickup_borough AS x,total_amount AS y from highest_paid_trip");
    }

    public List<Map<String, Object>> chart10() {
        return query("select vendor_id AS x,extra_cost AS y from top_extra_costs");
    }

    public List<Map<String, Object>> chart11() {
        return query("select payment_type,total,tip_pct from payment_type_analysis");
    }

    public List<Map<String, Object>> chart12() {
        return query("select vendor_id,dt,avg_total_price from vendor_daily_avg");
    }
}